#include "my_regester.h"
#include "ui_my_regester.h"

My_Regester::My_Regester(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::My_Regester)
{
    ui->setupUi(this);

    // 初始化数据库
    db = new DateBase(this);
}

My_Regester::~My_Regester()
{
    delete ui;
}

void My_Regester::on_Button_register_clicked()
{
    QString username = ui->lineEdit_count->text();
   QString password = ui->lineEdit_password->text();
   QString phone = ui->lineEdit_phone->text();

   // 数据验证
   if (username.isEmpty() || password.isEmpty() || phone.isEmpty()) {
       QMessageBox::warning(this, "错误", "所有字段都是必填的！");
       return;
   }

    db->registerUser(username , password ,phone );
}

void My_Regester::on_Button_return_clicked()
{
    // 隐藏自己
    this->hide();
    // 发送信号 让登录显示
    emit sig_register();
}
